/*
    Copyright 2010 Barnet Wagman

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 */

package com.norbl.util;

import java.io.*;

/** A <tt>Serializer</tt> handles the details of converting an object into
 *  the form in which it will be stored and reversing the process.
 *  E.g. {@link GzipSerializer} first serialized an object and then compresses
 *  it.
 *
 * @author Barnet Wagman
 */
public interface Serializer {
    
        /** Serializes the object to a byte array.
         * 
         * @param obj
         * @return object in a byte[].
         * @throws IOException
         */
    public byte[] objectToByteArray(Serializable obj) throws IOException;

        /** Deserializes an object in a byte array.
          *
          * @param B
          * @return object.
          * @throws InvalidClassException
          * @throws IOException
          * @throws ClassNotFoundException
          */
    public Object byteArrayToObject(byte[] B)
        throws InvalidClassException, IOException, ClassNotFoundException;
}
